// LanguageState.cpp: implementation of the CLanguageState class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "LanguageState.h"
#include "ListCtrl.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CLanguageState::CLanguageState(WCHAR* name):IStatu(name)
{

}

bool CLanguageState::upclick()
{
	CListCtrl* p = (CListCtrl*)GRAPHICMGR.GetElement(L"listCtrl_Language");
	if(p->LastPage())
	{
	GRAPHICMGR.SetChangeMode(4);
	GRAPHICMGR.SetChangeRect(p->m_RectPos);
	GRAPHICMGR.SetUpdateElements(L"listCtrl_Language",L"none");
	}
	//GRAPHICMGR.AllElementUpdate();
	
	return true;
}

bool CLanguageState::downclick()
{
	CListCtrl* p = (CListCtrl*)GRAPHICMGR.GetElement(L"listCtrl_Language");
	if (p->NextPage())
	{

		//GRAPHICMGR.AllElementUpdate();
		GRAPHICMGR.SetChangeMode(3);
		GRAPHICMGR.SetChangeRect(p->m_RectPos);
		GRAPHICMGR.SetUpdateElements(L"listCtrl_Language",L"none");
	}
	
	return true;
}
 bool CLanguageState::EvaluateClickEvent(const WCHAR* elementName)
 {
    
	 if (wcscmp(elementName,L"language_btn_listup") == 0)
		 return upclick();
	 else if (wcscmp(elementName,L"language_btn_listdown") == 0)
		 return downclick();
	 else if (wcscmp(elementName,L"listCtrl_Language") == 0)
		 return setlanguage();
	return false;

 }
 
 bool CLanguageState::EnterStatu()
 {
	 CListCtrl* p = (CListCtrl*)GRAPHICMGR.GetElement(L"listCtrl_Language");
	 if (p)
	 {
		 GlobalStatic::loadLanguage(p->m_mapFileName);
		 p->constructMap();
	 }
	 return true;
	 
 }
 
 //##ModelId=4668B9DC002E
 bool CLanguageState::ExitStatu()
 {
	 return true;
 }
 
 bool CLanguageState::setlanguage()
 {
     CListCtrl* p = (CListCtrl*)GRAPHICMGR.GetElement(L"listCtrl_Language");
	 int index=p->getSelectedIndex();
	GlobalStatic::ChangeLang((ELANG )index);
	 return true;
 }